import {type JSX, lazy} from "react";
import {camelCase} from "@/utils";

const modules = import.meta.glob('/src/pages/**/*.tsx');

type RouterMapType = Record<string, React.LazyExoticComponent<() => JSX.Element>>

const RouterMap: RouterMapType = {
    // Login: lazy(() => import(/* @vite-ignore */ '/src/pages/login/Login.tsx'))
}

for (const path in modules) {
    const name = path.replace('.tsx', '').split('/').pop()!
    // console.log(name)
    if (name) {
        const key =camelCase(name)
        // console.log(path)

        RouterMap[key] = lazy(() => import(/* @vite-ignore */ `${path}`));
        // 动态导入并传给 React.lazy
    }
}
export default RouterMap